# Contributor: fossdd <fossdd@pwned.life>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=chatterino2
pkgver=2.5.1
_crash_handler_commit=9753fe802710b2df00f2287ec2e1ca78c251d085
_libcommuni_commit=030710ad53dda1541601ccabbad36a12a9e90c78
_magicenum_commit=e55b9b54d5cf61f8e117cafb17846d7d742dd3b4
_miniaudio_commit=4a5b74bef029b3592c54b6048650ee5f972c1a48
_rapidjson_commit=d87b698d0fcc10a5f632ecbc80a9cb2a8fa094a5
_sanitizers_cmake_commit=3f0542e4e034aab417c51b2b22c94f83355dee15
_serialize_commit=17946d65a41a72b447da37df6e314cded9650c32
_settings_commit=70fbc7236aa8bcf5db4748e7f56dad132d6fd402
_signals_commit=d06770649a7e83db780865d09c313a876bf0f4eb
_websocketpp_commit=b9aeec6eaf3d5610503439b4fae3581d9aff08e8
pkgrel=0
pkgdesc="Chat client for twitch.tv"
url="https://chatterino.com/"
arch="all"
license="MIT"
depends="
	boost1.84-libs
	openssl
	qt6-qt5compat
	qt6-qtbase
	qt6-qtimageformats
	qt6-qtkeychain
	qt6-qtsvg
	qt6-qttools
	"
makedepends="
	boost-dev
	cmake
	openssl-dev
	qt6-qt5compat-dev
	qt6-qtbase-dev
	qt6-qtimageformats-dev
	qt6-qtsvg-dev
	qt6-qttools-dev
	qtkeychain-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/Chatterino/chatterino2/archive/refs/tags/v$pkgver.tar.gz
	$pkgname-crash-handler-$_crash_handler_commit.tar.gz::https://github.com/Chatterino/crash-handler/archive/$_crash_handler_commit.tar.gz
	$pkgname-serialize-$_serialize_commit.tar.gz::https://github.com/pajlada/serialize/archive/$_serialize_commit.tar.gz
	$pkgname-settings-$_settings_commit.tar.gz::https://github.com/pajlada/settings/archive/$_settings_commit.tar.gz
	$pkgname-signals-$_signals_commit.tar.gz::https://github.com/pajlada/signals/archive/$_signals_commit.tar.gz
	libcommuni-$_libcommuni_commit.tar.gz::https://github.com/Chatterino/libcommuni/archive/$_libcommuni_commit.tar.gz
	magicenum-$_magicenum_commit.tar.gz::https://github.com/Neargye/magic_enum/archive/$_magicenum_commit.tar.gz
	miniaudio-$_miniaudio_commit.tar.gz::https://github.com/mackron/miniaudio/archive/$_miniaudio_commit.tar.gz
	rapidjson-$_rapidjson_commit.tar.gz::https://github.com/Tencent/rapidjson/archive/$_rapidjson_commit.tar.gz
	sanitizers-cmake-$_sanitizers_cmake_commit.tar.gz::https://github.com/arsenm/sanitizers-cmake/archive/$_sanitizers_cmake_commit.tar.gz
	websocketpp-$_websocketpp_commit.tar.gz::https://github.com/zaphoyd/websocketpp/archive/$_websocketpp_commit.tar.gz
	"
options="!check" # more complex: requires to start 2 servers: https://github.com/Chatterino/chatterino2/tree/master/tests

prepare() {
	default_prepare

	mv "$srcdir"/crash-handler-*/* "$srcdir"/chatterino2-$pkgver/tools/crash-handler/
	mv "$srcdir"/libcommuni-*/* "$srcdir"/chatterino2-$pkgver/lib/libcommuni/
	mv "$srcdir"/magic_enum-*/* "$srcdir"/chatterino2-$pkgver/lib/magic_enum/
	mv "$srcdir"/miniaudio-*/* "$srcdir"/chatterino2-$pkgver/lib/miniaudio/
	mv "$srcdir"/rapidjson-*/* "$srcdir"/chatterino2-$pkgver/lib/rapidjson/
	mv "$srcdir"/sanitizers-cmake-*/* "$srcdir"/chatterino2-$pkgver/cmake/sanitizers-cmake/
	mv "$srcdir"/serialize-*/* "$srcdir"/chatterino2-$pkgver/lib/serialize/
	mv "$srcdir"/settings-*/* "$srcdir"/chatterino2-$pkgver/lib/settings/
	mv "$srcdir"/signals-*/* "$srcdir"/chatterino2-$pkgver/lib/signals/
	mv "$srcdir"/websocketpp-*/* "$srcdir"/chatterino2-$pkgver/lib/websocketpp/
}

build() {
	cmake \
		-DCMAKE_BUILD_TYPE=Release \
		-DUSE_SYSTEM_QTKEYCHAIN=ON \
		-DUSE_PRECOMPILED_HEADERS=OFF \
		-DBUILD_WITH_QT6=ON \
		-DCHATTERINO_UPDATER=OFF \
		.
	cmake --build .
}

package() {
	install -Dm755 bin/chatterino -t "$pkgdir"/usr/bin/
	install -Dm644 resources/com.chatterino.chatterino.desktop -t "$pkgdir"/usr/share/applications/
	install -Dm644 resources/icon.png "$pkgdir"/usr/share/pixmaps/com.chatterino.chatterino.png
}

sha512sums="
29595bbbd161783deeb6159188f9271565a86907158178dbfd5ba576c1896dac708e65785d671673fb071fc00047e918a3b7066f57ee2b370d6b21ef4c106f2e  chatterino2-2.5.1.tar.gz
750564ad7bc49de839f4a34d8e9b9311d2f492ca125801ee6d1b07047a967542154511ea0e115a886a955775b5524e17489e58b79f1ba1af45c952da61ee413b  chatterino2-crash-handler-9753fe802710b2df00f2287ec2e1ca78c251d085.tar.gz
2ea660b6f164b8ba5b419e8381272dca507fcab09434421915a9b4be5e95cba08e72e708f16b3b22f5e0cae6dab2ef332d0a7976c287f048710e328d9a8913be  chatterino2-serialize-17946d65a41a72b447da37df6e314cded9650c32.tar.gz
811dabaf1c90f1a614c1df8b7dbe791a16e658cbe36dc56b108006ee0a14d8b4ca58752e5e2fe088fe0a8b59966a93c9de5d5c0a172ee1556ba01326e6a6f4fc  chatterino2-settings-70fbc7236aa8bcf5db4748e7f56dad132d6fd402.tar.gz
5489151f2d036dc8834346f902cf740e1b1b6823d385d2bc7c5d715af6911ade9ee383c591c48bdb8bdfca70890f48e8333ee39c6319d3871239f99d34a51cc9  chatterino2-signals-d06770649a7e83db780865d09c313a876bf0f4eb.tar.gz
4a056c6c69b5a6b1f29118034f7769de68f06c99549714272f515182e118bb744ba43956795ec42f1b283c89c30db53b19ac27988c31d185132ce71741e3b062  libcommuni-030710ad53dda1541601ccabbad36a12a9e90c78.tar.gz
466ba8e6e9122e55fb49b1a842b3f88ddc5faa5ea096df445dec1feba0c9db09748e735874b7839bf5f822f39480fa556a6bfaac0855c065df23b00ce45c5b3d  magicenum-e55b9b54d5cf61f8e117cafb17846d7d742dd3b4.tar.gz
d9328238e738280fccc34ae0d6d6ac68a171a30aef53defd5d74b6991b1c8dd63d0d433ede52d50f191984cefdabf414913b3f458d39a4fe16e0ade4beefaf7a  miniaudio-4a5b74bef029b3592c54b6048650ee5f972c1a48.tar.gz
1770668c954e1bfa40da3956ccf2252703d2addb058bb8c0bf579abac585262452d0e15dcfed9ac2fa358c0da305d706226fdab8310b584017aba98e4f31db4f  rapidjson-d87b698d0fcc10a5f632ecbc80a9cb2a8fa094a5.tar.gz
10cd4eeb3bbb7bf5c6f5cf8b5bc6a531b1ec8bdc147583d8de028a3e4b8b9d0e258aad81f02135267ce8f7d87b30999dedd25b44c0754b5c31e00d8481cd412f  sanitizers-cmake-3f0542e4e034aab417c51b2b22c94f83355dee15.tar.gz
5449a10086c1b80d0d2865bac90539f64613156050816e97a2da1a2bc1f6710ac72305747e839a13e49b2ce1b25610480c110743aef60d7d148f2c39339289c4  websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.tar.gz
"
